<!DOCTYPE html>
<!-- 
  Copyright 2011 Google Inc. All Rights Reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<html>
  <body>
    <pre id='code'>
// Controls.
year = new
  google.visualization.ControlWrapper({
    controlType : 'CategoryFilter',
    containerId : 'year',
    options: {
      filterColumnLabel: 'Year',
      values: [1960, 1970, 1980, 1990, 2000, 2008],
      ui: {
        allowMultiple: false,
        allowTyping: false,
        labelStacking: 'horizontal',
      }
    },
    state: {
      selectedValues: [2008]
    }
  });

country = new
  google.visualization.ControlWrapper({
    controlType: 'CategoryFilter',
    containerId: 'country',
    options: {
      filterColumnLabel: 'Country Name',
      ui: {
        allowMultiple: true,
        allowTyping: true,
        selectedValuesLayout: 'below',
        labelStacking: 'horizontal'
      }
    }
  });

gdp = new
  google.visualization.ControlWrapper({
    controlType: 'NumberRangeFilter',
    containerId: 'gdp',
    options: {
      filterColumnIndex: 2
    }
  });

expectancy = new
  google.visualization.ControlWrapper({
    controlType: 'NumberRangeFilter',
    containerId: 'expectancy',
    options: {
      filterColumnIndex: 3
    }
  });

// Charts
pie =
  new google.visualization.ChartWrapper({
    chartType: 'PieChart',
    containerId: 'pie',
    options: {
      width: 300,
      height: 300,
      legend: 'none',
      sliceVisibilityThreshold: 1/60
    },
    view: {columns: [1,2]}
  });

geo = new
  google.visualization.ChartWrapper({
    chartType: 'GeoChart',
    containerId: 'geo',
    options: {
      region:'world',
      colors: [ '#D6F1FF', '#0A43BF' ],
      width: 510,
      height: 300
    },
    view: {columns: [1,3]}
  });

metric = document.getElementById('metric');
metric.onchange =
  function(evt) {
    if (evt.target.selectedIndex == 0) {
      // Expectancy
      geo.setView({'columns': [1, 3]});
    } else {
      geo.setView({'columns':  [1, 2]});
    }
    geo.draw();
  };

scatter = new
  google.visualization.ChartWrapper({
    chartType: 'ScatterChart',
    containerId: 'scatter',
    options: {
      hAxis: {
        title: 'GDP',
        minValue: 100,
        maxValue: 1000000,
        logScale: true
      },
      vAxis: {
        title: 'Expectancy',
        minValue: 20,
        maxValue: 100
      },
      legend: 'none',
      height: 200,
      width: 300
    },
    view: {columns: [2, 3]}
  });
  
dashboard = new
  google.visualization.Dashboard(
      document.getElementById('errors'));

// Bindings.
dashboard.bind(
  [year, country, gdp, expectancy],
  [pie, geo, scatter]);
dashboard.bind(
  [year, country], [gdp, expectancy]);
dashboard.bind(
  [expectancy], [gdp]);

// Gentlemen (and ladies), start your engines.
dashboard.draw(dataTable);</pre>
    <div id='content_4' class='inlineParticipants'>
      <div id="year" class="control" style='display: inline-block'></div>
      <div id="country" class="control"></div>
      <div id="expectancy" class="control" style='display: inline-block'></div>
      <div id="gdp" class="control"></div>

      Metric: <select id='metric'>
        <option value="expectancy">Life Expectancy</option>
        <option value="gdp">GDP</option>
      </select>
      <div id="geo" class="chart" style="width: 510px; height: 300px"></div>
      <div id="pie" class="chart"></div>
      <div id="scatter" class="chart"></div>
    </div>
    <script>
      parent.editor.addShortCut(
        '4',
        document.getElementById('code'),
        document.getElementById('content_4').cloneNode(true));
    </script>
  </body>
</html>
